package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.AgvTask;
import com.ruoyi.system.service.IAgvTaskService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * AGV任务中间 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-22
 */
@Controller
@RequestMapping("/system/agvTask")
public class AgvTaskController extends BaseController
{
    private String prefix = "system/agvTask";
	
	@Autowired
	private IAgvTaskService agvTaskService;
	
	@RequiresPermissions("system:agvTask:view")
	@GetMapping()
	public String agvTask()
	{
	    return prefix + "/agvTask";
	}
	
	/**
	 * 查询AGV任务中间列表
	 */
	@RequiresPermissions("system:agvTask:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(AgvTask agvTask)
	{
		startPage();
        List<AgvTask> list = agvTaskService.selectAgvTaskList(agvTask);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出AGV任务中间列表
	 */
	@RequiresPermissions("system:agvTask:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgvTask agvTask)
    {
    	List<AgvTask> list = agvTaskService.selectAgvTaskList(agvTask);
        ExcelUtil<AgvTask> util = new ExcelUtil<AgvTask>(AgvTask.class);
        return util.exportExcel(list, "agvTask");
    }
	
	/**
	 * 新增AGV任务中间
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存AGV任务中间
	 */
	@RequiresPermissions("system:agvTask:add")
	@Log(title = "AGV任务中间", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(AgvTask agvTask)
	{		
		return toAjax(agvTaskService.insertAgvTask(agvTask));
	}

	/**
	 * 修改AGV任务中间
	 */
	@GetMapping("/edit/{taskid}")
	public String edit(@PathVariable("taskid") String taskid, ModelMap mmap)
	{
		AgvTask agvTask = agvTaskService.selectAgvTaskById(taskid);
		mmap.put("agvTask", agvTask);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存AGV任务中间
	 */
	@RequiresPermissions("system:agvTask:edit")
	@Log(title = "AGV任务中间", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(AgvTask agvTask)
	{		
		return toAjax(agvTaskService.updateAgvTask(agvTask));
	}
	
	/**
	 * 删除AGV任务中间
	 */
	@RequiresPermissions("system:agvTask:remove")
	@Log(title = "AGV任务中间", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(agvTaskService.deleteAgvTaskByIds(ids));
	}
	
}
